package com.yfp.common.core.enums;

import com.yfp.common.core.exception.ServiceException;
import lombok.Getter;

import java.util.Objects;

/**
 * 短信类型
 *
 *
 * @date 2023/12/06
 */
@Getter
public enum SmsTypeEnum {
    /**
     * 通用获取验证码
     */
    CURRENCY("SMS_317160245", "1"),
    /**
     * 忘记密码
     */
    FORGOT_PASSWORD("forgotPassword", "2"),
    /**
     * 修改密码
     */
    CHANGE_PASSWORD("changePassword", "3"),
    /**
     * 登录
     */
    LOGIN("login", "4");

    private final String type;
    private final String code;

    SmsTypeEnum(String type, String code) {
        this.type = type;
        this.code = code;
    }

    public static String getSmsTemplateByCode(String code) {
        for (SmsTypeEnum smsTypeEnum : SmsTypeEnum.values()) {
            if (Objects.equals(smsTypeEnum.code, code)) {
                return smsTypeEnum.type;
            }
        }
       throw new ServiceException("短信模版不存在");
    }

}
